package com.gongyinlian.personalprofilewebsiteserver.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 统一返回状态码枚举
 * 
 * @author personal-profile-website
 * @date 2024-10-27
 */
@Getter
@AllArgsConstructor
public enum ResultCode {
    
    // ========== 通用状态码 ==========
    SUCCESS(200, "操作成功"),
    FAILED(500, "操作失败"),
    
    // ========== 客户端错误 4xx ==========
    BAD_REQUEST(400, "请求参数错误"),
    UNAUTHORIZED(401, "未授权，请先登录"),
    FORBIDDEN(403, "没有权限访问该资源"),
    NOT_FOUND(404, "请求的资源不存在"),
    METHOD_NOT_ALLOWED(405, "请求方法不支持"),
    REQUEST_TIMEOUT(408, "请求超时"),
    CONFLICT(409, "数据冲突"),
    
    // ========== 服务器错误 5xx ==========
    INTERNAL_SERVER_ERROR(500, "服务器内部错误"),
    SERVICE_UNAVAILABLE(503, "服务暂时不可用"),
    
    // ========== 业务错误码 1xxx ==========
    BUSINESS_ERROR(1000, "业务处理失败"),
    
    // ========== 参数验证错误 2xxx ==========
    VALIDATE_FAILED(2001, "参数验证失败"),
    PARAM_IS_BLANK(2002, "参数为空"),
    PARAM_TYPE_ERROR(2003, "参数类型错误"),
    PARAM_NOT_COMPLETE(2004, "参数缺失"),
    
    // ========== 用户相关错误 3xxx ==========
    USER_NOT_EXIST(3001, "用户不存在"),
    USER_ACCOUNT_DISABLED(3002, "账号已被禁用"),
    USER_DISABLED(3002, "用户已被禁用"),
    USER_ACCOUNT_LOCKED(3003, "账号已被锁定"),
    USER_ACCOUNT_EXPIRED(3004, "账号已过期"),
    USERNAME_OR_PASSWORD_ERROR(3005, "用户名或密码错误"),
    PASSWORD_ERROR(3005, "密码错误"),
    USERNAME_ALREADY_EXISTS(3006, "用户名已存在"),
    EMAIL_ALREADY_EXISTS(3007, "邮箱已存在"),
    PHONE_ALREADY_EXISTS(3008, "手机号已存在"),
    OLD_PASSWORD_ERROR(3009, "原密码错误"),
    
    // ========== Token 相关错误 4xxx ==========
    TOKEN_EXPIRED(4001, "Token已过期"),
    TOKEN_INVALID(4002, "Token无效"),
    TOKEN_MISSING(4003, "Token缺失"),
    TOKEN_PARSE_ERROR(4004, "Token解析失败"),
    REFRESH_TOKEN_EXPIRED(4005, "刷新Token已过期"),
    REFRESH_TOKEN_INVALID(4006, "刷新Token无效"),
    
    // ========== 权限相关错误 5xxx ==========
    PERMISSION_DENIED(5001, "权限不足"),
    ROLE_NOT_EXIST(5002, "角色不存在"),
    
    // ========== 数据相关错误 6xxx ==========
    DATA_NOT_EXIST(6001, "数据不存在"),
    DATA_ALREADY_EXISTS(6002, "数据已存在"),
    DATA_IS_REFERENCED(6003, "数据被引用，无法删除"),
    DATA_VERSION_CONFLICT(6004, "数据版本冲突"),
    
    // ========== 文件相关错误 7xxx ==========
    FILE_UPLOAD_FAILED(7001, "文件上传失败"),
    FILE_SIZE_EXCEED(7002, "文件大小超出限制"),
    FILE_TYPE_NOT_ALLOWED(7003, "文件类型不允许"),
    FILE_NOT_EXIST(7004, "文件不存在"),
    FILE_DOWNLOAD_FAILED(7005, "文件下载失败"),
    
    // ========== 第三方服务错误 8xxx ==========
    THIRD_PARTY_SERVICE_ERROR(8001, "第三方服务调用失败"),
    SMS_SEND_FAILED(8002, "短信发送失败"),
    EMAIL_SEND_FAILED(8003, "邮件发送失败"),
    
    // ========== 系统错误 9xxx ==========
    DATABASE_ERROR(9001, "数据库错误"),
    REDIS_ERROR(9002, "Redis错误"),
    NETWORK_ERROR(9003, "网络错误"),
    SYSTEM_BUSY(9004, "系统繁忙，请稍后再试");
    
    /**
     * 状态码
     */
    private final Integer code;
    
    /**
     * 消息
     */
    private final String message;
}

